﻿using IOP.Pulsar.Default;
using IOP.Pulsar.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading.Tasks;
using IOP.Pulsar.Abstractions;
using System.Text;

namespace PulsarIntegrationTest
{
    public class Startup : IStartup
    {
        public void Configure(IServerBuilder server, IHostEnvironment env)
        {
            server.BuildPipeline<StringContext>(builder =>
            {
                builder.Run(end =>
                {
                    Console.WriteLine(end.Body);
                    end.Socket.Send(Encoding.UTF8.GetBytes($"服务端收到消息:{end.Body}\r\n"));
                    return Task.CompletedTask;
                });
            });
        }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDefaultProductLineEntry();
        }
    }
}
